<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/23
 * Time: 15:37
 */

namespace App\Game\Traits;


trait VrTrait
{
    public function apiDataParse(array $apiData, array $data)
    {
        $data = $this->statusParse($apiData, $data);
        //$data = $this->usernamePre($data);
        return $data;
    }

    private function statusParse(array $apiData, array $data)
    {
        if (array_key_exists('state', $apiData)) {
            if ($apiData['state'] == 2 || $apiData['state'] == 3) {
                $data['status'] = 1;
            } elseif ($apiData['state'] == 1) {
                $data['status'] = -1;
            } else {
                $data['status'] = 0;
            }
        }
        return $data;
    }

    private function usernamePre(array $data)
    {
        if (array_key_exists('username', $data)) {
            $data['username'] = str_after($data['username'], $this->clearPre);
        }
        return $data;
    }


}